package com.platform.qujia.config;

import io.swagger.annotations.Api;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

/***
 * <Title> SwaggerConfig </Title>
 * <Description> Swagger2相关的自定义配置 </Description>
 * @Author JK
 * @Date 2021年7月2日
 */

@Configuration
@EnableSwagger2
@ConditionalOnProperty(prefix = "swagger2", name = "swagger-ui-open", havingValue = "true")
public class SwaggerConfig {

    @Bean
    public Docket createRestApi(){
        return new Docket(DocumentationType.SWAGGER_2)
                .apiInfo(new ApiInfoBuilder()
                        .title("趣伽接口平台")
                        .description("趣伽接口")
                        //.termsOfServiceUrl("www.huijy.net")
                        .version("1.0.1")
                        .build())
                .select()
                .apis(RequestHandlerSelectors.withClassAnnotation(Api.class))
                .apis(RequestHandlerSelectors.basePackage("com.platform.qujia.controller"))
                .paths(PathSelectors.any())
                .build();
    }
}
